﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace OpenLab.UI.Helper
{
    class CustomeTextBox : TextBox
    {
        bool _isArabic;
        [Localizable(true)]
        [Category("Data")]
        public bool IsArabic
        {
            get
            {

                return _isArabic;
            }
            set
            {
                _isArabic = value;
            }
        }


        public CustomeTextBox()
        {
            this.Leave += new EventHandler(CustomeTextBox_Leave);
            this.Enter += new EventHandler(CustomeTextBox_Enter);
        }

        public static InputLanguageHelper KayboardLaoutHelper = new InputLanguageHelper(); 
        private InputLanguage _CurrentKeyboard;
        void CustomeTextBox_Enter(object sender, EventArgs e)
        {
            _CurrentKeyboard = InputLanguage.CurrentInputLanguage;

            if (IsArabic)
            {

                KayboardLaoutHelper.LoadArabicKeyboardLayout();
            }
            else
            {

                KayboardLaoutHelper.LoadEnglishKeyboardLayout();
            }
        }

        void CustomeTextBox_Leave(object sender, EventArgs e)
        {
            KayboardLaoutHelper.SetKeyboardLayout(_CurrentKeyboard);
        }
    }
}
